package proyectoX;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
/**
 * Clase que implementa el menu del juego.
 * @author Daprotis Mauro - Heiland Federico
 *
 */
@SuppressWarnings("serial")
public class Menu extends JFrame {
    JPanel panel;
    JButton comenzar, salir;
    JComboBox nivelCombo,robots;
    JLabel nivelLabel,robotLabel;
/**
 * Construcor del menu.
 */
    public Menu() {
        initGui();
        super.setTitle("Lingo 2");
        getContentPane().add(panel);
        pack();
        setLocationRelativeTo(null);
        setResizable(false);
        setVisible(true);
        comenzar.setFocusable(true);
    }
/**
 * Inicializa la interfaz grafica.
 */
    private void initGui() {
        panel = new JPanel();
        
        
        nivelLabel = new JLabel("Selecciona un nivel:");
        nivelCombo = new JComboBox(new String[]{"Nivel Militar 1","Nivel Militar 2","Nivel Civil 1"});
       robots = new JComboBox(new String[]{"Civil","Militar"});
        robots.setSelectedIndex(1);
        robotLabel = new JLabel("Seleccione un Robot:");
        
        

        comenzar = new JButton(new AbstractAction("Empeza!") {

            public void actionPerformed(ActionEvent e) {
               
                int nivel = nivelCombo.getSelectedIndex();
                if (robots.getSelectedIndex()==0 && nivel!=2)
                	JOptionPane.showMessageDialog(null, "Necesitas un Robot Militar para ese nivel!");
          	
                else
                {	new GUI(robots.getSelectedIndex(),nivel);
                    dispose();
                }
                
            }
        });


        salir = new JButton(new AbstractAction("Salir") {

            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });

        panel.setLayout(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.BOTH;
        c.gridx = 0;
        c.gridy = 0;
        c.insets = new Insets(5,5,5,5);
        panel.add(robotLabel, c);
        c.gridx = 1;
        c.gridy = 0;
        panel.add(robots, c);
        c.gridx = 0;
        c.gridy = 2;
        panel.add(nivelLabel, c);
        c.gridx = 1;
        c.gridy = 2;
        panel.add(nivelCombo, c);
        c.gridx = 0;
        c.gridy = 3;
        panel.add(comenzar, c);
        c.gridx = 1;
        c.gridy = 3;
        panel.add(salir, c);

    }
}
